$("#getGifCode").click(function () {
    code();
});
function code() {
    $("#getGifCode").attr('src','getGifCode?a='+Math.random());//链接后添加Math.random，确保每次产生新的验证码，避免缓存问题。
}
if(top.location!=self.location){
    window.top.location = "/login";
}
layui.use(['layer', 'form'], function() {
    var form = layui.form;
    form.on('submit(login)', function() {
        Layer.showLogin('正在努力登录中...')
        console.log($('#login').serialize());
        $.post("/login", $('#login').serialize(), function (result) {
            if (result && result.status != "success") {
                code();
                msgs(result.errorMsg);
                Layer.headLogin();
            } else {
                window.location.href = "/"
            }
        });
        return false;
    });
});
function msgs(message) {
    $(".form-message").show();
    $(".form-message").empty().text(message);
}